﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ImageRecognition2.Action
{
    /// <summary>
    /// Use this to zoom a pic
    /// </summary>
    public class ActionZoom : AbstractCommand
    {
        private float m_fZoomLevel = 1.0f;
        private bool m_bZoomIn = true;

        /// <summary>
        /// Initializes a new instance of the <see cref="ActionZoom"/> class.
        /// </summary>
        public ActionZoom()
        { 
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ActionZoom"/> class.
        /// </summary>
        /// <param name="_bZoomIn">if set to <c>true</c> [_b zoom in].</param>
        public ActionZoom(bool _bZoomIn)
        {
            m_bZoomIn = _bZoomIn;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ActionZoom"/> class.
        /// </summary>
        /// <param name="_fZoomLevel">The _f zoom level.</param>
        public ActionZoom(float _fZoomLevel)
        {
            m_fZoomLevel = _fZoomLevel;
        }

        /// <summary>
        /// Gets or sets a value indicating whether [zoom in].
        /// </summary>
        /// <value><c>true</c> if [zoom in]; otherwise, <c>false</c>.</value>
        public bool ZoomIn        
        {
            get { return m_bZoomIn; }
            set { m_bZoomIn = value; }
        }

        /// <summary>
        /// Runs the specified sender.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public override void Run(object sender, EventArgs e)
        {
            MainFormSingleton.ActivePictureBox.Zoom = m_bZoomIn ? MainFormSingleton.ActivePictureBox.Zoom + 1.0f : MainFormSingleton.ActivePictureBox.Zoom - 1.0f;
        }

        /// <summary>
        /// Gets or sets the zoom level.
        /// </summary>
        /// <value>The zoom level.</value>
        public float ZoomLevel
        {
            get { return m_fZoomLevel; }
            set { m_fZoomLevel = value; }
        }
    }
}
